using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Configuration;
using Microsoft.IdentityModel.Tokens;
using Ocelot.Administration;
using Ocelot.DependencyInjection;
using Ocelot.Middleware;
using Ocelot.Provider.Consul;
using Ocelot.Provider.Polly;
using System;

namespace OcelotGatewayProj
{
    class Program
    {
        static void Main(string[] args)
        {
            WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
            builder.Configuration.AddJsonFile("ocelot.json");


            Action<JwtBearerOptions> jwtOption = o =>
            {
                o.Authority = "";//identityServerRootUrl;
                o.RequireHttpsMetadata = false;
                o.TokenValidationParameters = new TokenValidationParameters
                {
                    ValidateAudience = false,
                };
                // etc....
            };
            builder.Services
                .AddOcelot()
                .AddConsul()
                .AddPolly();
                //.AddAdministration("/administration", jwtOption);//.AddConfigStoredInConsul();

            WebApplication app = builder.Build();
            app.UseOcelot().Wait();

            app.Run();
        }

    }
}